package cn.zr.aitool.model;

import android.text.TextUtils;

import java.util.ArrayList;

import cn.zr.aitool.bean.ContentBean;

/**
 * 文件名称:
 * 功能描述:
 * 创建者: zhengrui
 * 创建时间: 2018/8/28
 * 修改者: zhengrui
 * Copyright (C) 2017 猎户星空
 *
 * @author zhengrui
 */
public class GuPiaoImpl extends BaseContentModal {
    public GuPiaoImpl(ContentBean mBean) {
        super(mBean);
    }

    @Override
    public ArrayList<String> getContentHint() {
        ArrayList<String> hints = new ArrayList<>();
        hints.add("名称");
        hints.add("价格");
        hints.add("数量");
        hints.add("原因");
        return hints;
    }

    @Override
    public String getDescribeByType() {
        return mBean.type == 0 ? "买入" : "卖出";
    }

    public int getCount() {
        if (!TextUtils.isEmpty(mBean.content1)) {
            if (mBean.type == 0) {
                String[] temps = mBean.content1.split(":");
                try {
                    return Integer.valueOf(temps[1]);
                } catch (Exception e) {

                }
            }
        }
        return 0;
    }

    public float getPrice() {
        if (!TextUtils.isEmpty(mBean.content)) {
            if (mBean.type == 0) {
                String[] temps = mBean.content.split(":");
                try {
                    return Float.valueOf(temps[1]);
                } catch (Exception e) {

                }
            }
        }
        return 0f;
    }

    public float getCost() {
        return getCount() * getPrice();
    }
}
